# 获取并加载 json
from langchain_text_splitters import RecursiveJsonSplitter
import requests
url = "https://api.smith.langchain.com/openapi.json"
json_data = requests.get(url).json()

# 递归json分割器
text_splitter = RecursiveJsonSplitter(max_chunk_size=300)

# 分割json数据并创建
json_chunks = text_splitter.split_json(json_data=json_data)
chunks = text_splitter.create_documents(json_chunks)

for chunk in chunks:
    print(chunk)

print(len(chunks))